package utils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

/**
 * @Author: DRevelation
 * @Date: 2021/4/6 16:42
 */
public class HtmlUtils {
    public static void main(String[] args) {
        String htmlStr = "<p class=\"ke-photo-block\" key-photo-id=\"3509\" key-photo-title=\"测试图集设置封面图\"\n" +
                "    key-photo-show-url=\"http://zbbf9-hw.ahtv.cn/ahtv-obs/20210312/0be25406-24eb-cf4f-c48e-0fd4a8da1c09.png\"\n" +
                "    key-photo-length=\"2\" style=\"width: 100%;position: relative;\">\n" +
                "    < img class=\"ke-photo-show ke-photo-3509\" key-photo-id=\"3509\" style=\"width: 100%;height: 200px;object-fit: cover\"\n" +
                "        src=\"http://zbbf9-hw.ahtv.cn/ahtv-obs/20210312/0be25406-24eb-cf4f-c48e-0fd4a8da1c09.png\" key=\"3509\" alt=\"\"><span\n" +
                "            class=\"ke-number-3509\"\n" +
                "            style=\"position: absolute;bottom: 10px;right: 10px;background: rgba(0, 0, 0, .6);color: #fff;border-radius: 20px;padding: 3px 15px;\">共2张</span><span\n" +
                "            class=\"ke-title-3509\"\n" +
                "            style=\"position: absolute;top: 10px;left: 10px;background: rgba(0, 0, 0, .6);color: #fff;border-radius: 20px;padding: 3px 15px;\">测试图集设置封面图</span>\n" +
                "</p>\n" +
                "<p><br></p>\n" +
                "<p class=\"ke-photo-block\" key-photo-id=\"3520\" key-photo-title=\"测试图集设置封面图(1)\"\n" +
                "    key-photo-show-url=\"http://zbbf9-hw.ahtv.cn/ahtv-obs/20210312/0be25406-24eb-cf4f-c48e-0fd4a8da1c09.png\"\n" +
                "    key-photo-length=\"5\" style=\"width: 100%;position: relative;\">\n" +
                "    < img class=\"ke-photo-show ke-photo-3520\" key-photo-id=\"3520\" style=\"width: 100%;height: 200px;object-fit: cover\"\n" +
                "        src=\"http://zbbf9-hw.ahtv.cn/ahtv-obs/20210312/0be25406-24eb-cf4f-c48e-0fd4a8da1c09.png\" key=\"3520\" alt=\"\"><span\n" +
                "            class=\"ke-number-3520\"\n" +
                "            style=\"position: absolute;bottom: 10px;right: 10px;background: rgba(0, 0, 0, .6);color: #fff;border-radius: 20px;padding: 3px 15px;\">共5张</span><span\n" +
                "            class=\"ke-title-3520\"\n" +
                "            style=\"position: absolute;top: 10px;left: 10px;background: rgba(0, 0, 0, .6);color: #fff;border-radius: 20px;padding: 3px 15px;\">测试图集设置封面图(1)</span>\n" +
                "</p>\n" +
                "<p><br></p>\n" +
                "<p><br></p>";

        Document document = Jsoup.parse(htmlStr);
        String photo = document.select(".ke-photo-3509").attr("src");
        String num = document.select(".ke-number-3509").text();
        String title = document.select(".ke-title-3509").text();

        System.out.println("photo = " + photo);
        System.out.println("num = " + num);
        System.out.println("title = " + title);
    }
}
